#ifndef _IRRLICHT_ENGINE_H_
#define _IRRLICHT_ENGINE_H_

#include "StrawGUI.h"
#include "sIrrConfig.h"

#include <Windows.h>
#include <gl/GL.h>

namespace sgui
{
namespace engine
{

class sIrrlichtTexture;
class sIrrlichtFont;
class sIrrlichtDrawContext;

class sIrrlichtEngine : public sEngine
{
private:
    irr::video::IVideoDriver*       m_driver;
    irr::IrrlichtDevice*            m_device;

    template <typename T> 
    static const irr::core::position2d<T> toPosition2d(const sgui::math::sPoint<T>& p)
    {
        return irr::core::position2d<T>(p.getX(), p.getY());
    }

    template <typename T> 
    static const irr::core::rect<T> toRect(const sgui::math::sRect<T>& p)
    {
        const sgui::math::sPoint<T>& resSz = p.getPosition() + p.getSize();
        return irr::core::rect<T>(toPosition2d<T>(p.getPosition()), toPosition2d<T>(resSz));
    }

    friend sIrrlichtFont;
    friend sIrrlichtTexture;
    friend sIrrlichtDrawContext;
public:
    sTexture* getTexture(const res::sTextureResource& res, const preset::sTexturePreset& preset);
    sFont* getFont(const res::sFontResource& res, const preset::sFontPreset& preset);
	sDrawContext* getContext(const math::sRectf& rect);

    void beginDraw() const;
	void endDraw() const;

	void drawRect(const math::sRectf& rect, u32 color = 0xFFFFFFFF, bool fill = false) const;

    irr::video::IVideoDriver&      getDriver();
    irr::IrrlichtDevice&           getDevice();

    irr::video::IVideoDriver&      getDriver() const;
    irr::IrrlichtDevice&           getDevice() const;
    sIrrlichtEngine(irr::video::IVideoDriver* driver, irr::IrrlichtDevice* device);
};

};
};

#endif